<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateNewsTable extends Migration
{
    /**
     * Run the 资讯表
     *
     * @return void
     */
    public function up() {
        Schema::create('news', function (Blueprint $table) {
            $table->engine='MyISAM';
            $table->comment='资讯信息表';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->string('title',100)->default('')->comment('标题');
            $table->text('editorValue')->default('')->comment('内容');
            $table->string('source',100)->default('')->comment('来源');
            $table->string('publisher',100)->default('')->comment('发布者');
            $table->tinyInteger('category')->index('category')->default(0)->comment('一级类ID');
            $table->string('cid',100)->index('cid')->default('')->comment('所属类型id,用;进行分割');
            $table->string('style',50)->default('')->comment('标题颜色风格');
            $table->tinyInteger('recommend')->unsigned()->default(0)->comment('推荐');
            $table->integer('readnum')->unsigned()->default(0)->comment('阅读量');
            $table->timestamps();
        });
        Schema::create('news_category', function (Blueprint $table) {
            $table->engine='MyISAM';
            $table->comment='资讯分类表';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->tinyInteger('pid')->unsigned()->default(0)->comment('父类id');
            $table->string('new_sign',100)->index('new_sign')->default('')->comment('分类标识');
            $table->mediumInteger('descid')->unsigned()->default(0)->comment('子类id');
            $table->mediumInteger('level')->unsigned()->default(0)->comment('子类id');
            $table->string('defectsname',50)->default('')->comment('类别名称');
        });

        Schema::create('news_img_exist', function (Blueprint $table) {
            $table->engine='MyISAM';
            $table->comment='资讯图片表';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('news_id')->unsigned()->comment('新闻id');
            $table->string('img_url',100)->default('')->comment('文件路径名');
            $table->tinyInteger('img_state')->unsigned()->default(0)->comment('状态');
            $table->string('img_tag',40)->default('')->comment('跟踪用户的标记');
            $table->timestamps();
        });

    }
    public function down(){
        Schema::drop('news');
        Schema::drop('news_category');
        Schema::drop('news_img_exist');
    }
}
